import request from '@/utils/request'

/**
 * 获取员工简单列表
 */
export const getEmployeesSimple = () => {
  return request({
    url: '/sys/user/simple'
  })
}

/**
 * 获取员工列表
 * @param {*} params {}
 */
export const getEmployeesList = params => {
  return request({
    url: '/sys/user',
    params
  })
}

/**
 * 新增员工
 * @param {*} data {}
 */
export const addEmployees = data => {
  return request({
    url: '/sys/user',
    method: 'POST',
    data
  })
}

/**
 * 删除员工接口
 */
export const delEmployees = id => {
  return request({
    url: `/sys/user/${id}`,
    method: 'DELETE'
  })
}

/**
 * 批量导入员工
 * @param {*} data []
 */
export const importEmployees = data => {
  return request({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}

/**
 * 根据id获取员工信息
 * @param {*} id 员工id
 */
export const getEmployeesInfo = id => {
  return request({
    url: '/sys/user/' + id
  })
}

/**
 * 更新员工账号信息
 * @param {*} data 员工信息对象
 */
export const updateEmployees = data => {
  return request({
    url: '/sys/user/' + data.id,
    method: 'PUT',
    data
  })
}

/**
 * 获取员工详细信息
 * @param {*} id 员工id
 */
export const getEmployeesDetail = id => {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}

/**
 * 更新员工详细数据
 * @param {*} data {}
 */
export const updateEmployeesDetail = data => {
  return request({
    url: `/employees/${data.id}/personalInfo`,
    method: 'PUT',
    data
  })
}

/**
 * 获取员工岗位信息
 * @param {*} id 员工id
 */
export const getEmployeesJob = id => {
  return request({
    url: `/employees/${id}/jobs`
  })
}

/**
 * 更新员工岗位信息
 * @param {*} data 更新员工岗位信息对象
 */
export const updateEmployeesJob = data => {
  return request({
    url: `/employees/${data.id}/jobs`,
    method: 'PUT',
    data
  })
}

/**
 * 给员工分配角色
 * @param {*} data 对象：包含id(员工id) roleIds(角色id的集合)
 */
export const updateEmployeesRoles = data => {
  return request({
    url: '/sys/user/assignRoles',
    method: 'PUT',
    data
  })
}
